"use strict";
/**
 * @ Author: Yoann Meclot. MSay2
 * @ Created on: 2020-09-02 15:44:37
 * @ Modified on: 2020-09-29 10:51:30
 *
 * @version 1.2
 */
/**
 * Copyright (c) 2020 MSay2, Yoann Meclot - @msay2/tspoet
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
Object.defineProperty(exports, "__esModule", { value: true });
exports.TSVariable = void 0;
const ArrayList_js_1 = require("../utils/ArrayList.js");
const Utils_js_1 = require("../utils/Utils.js");
/**
 * Init a new variable
 *
 * @class TSVariable
 * @version 1.1
 */
class TSVariable {
    constructor(builder) {
        this.name = Utils_js_1.Utils.checkNotNull(builder.name, "TSVariable must have a non-null variable name.");
        this.typeName = Utils_js_1.Utils.checkNotNull(builder.typeName, "TSVariable must have a non-null variable type.");
        this.modifiers = Utils_js_1.Utils.checkNotNull(builder.modifiers, "TSVariable must have a non-null modifiers.");
        this.value = builder.value;
    }
    /**
     * Set a name.
     *
     * @param name The name of the variable.
     * @type {Builder}
     * @since 1.0
     */
    static add(name) {
        return new Builder(name);
    }
    emit(codeWriter) {
        codeWriter.emitVariable(this);
        return codeWriter;
    }
}
exports.TSVariable = TSVariable;
/**
 * @version 1.1
 */
class Builder {
    constructor(name) {
        this.modifiers = new ArrayList_js_1.ArrayList();
        this.name = name;
    }
    /**
     * Add modifiers for the variable.
     *
     * @param modifiers The modifiers to be added.
     * @throws {NullPointerException} Check if the modifiers is null.
     * @type {Builder}
     * @since 1.0
     */
    addModifiers(...modifiers) {
        this.modifiers = ArrayList_js_1.Arrays.asList(Utils_js_1.Utils.checkNotNull(modifiers, "TSVariable must have a non-null modifiers."));
        return this;
    }
    /**
     * Specify a return type.
     *
     * @param typeName The return type.
     * @throws {NullPointerException} Check if the TypeName object is null.
     * @type {Builder}
     * @since 1.0
     */
    return(typeName) {
        this.typeName = Utils_js_1.Utils.checkNotNull(typeName, "TSVariable must have a non-null variable type.");
        return this;
    }
    /**
     * Set a value.
     *
     * @param value The value of the variable.
     * @type {Builder}
     * @since 1.0
     */
    setValue(value) {
        this.value = value;
        return this;
    }
    /**
     * Build the variable.
     *
     * @type {TSVariable}
     * @throws {NullPointerException} Check if the name is null.
     * @throws {NullPointerException} Check if the modifiers is null.
     * @throws {NullPointerException} Check if the type name is null.
     * @since 1.0
     */
    build() {
        return new TSVariable(this);
    }
}
//# sourceMappingURL=TSVariable.js.map